package com.tuniu.agents.evaluator;

import java.util.HashMap;
import java.util.Map;

/**
 * Evaluation Result class
 * Used to store the result information of the evaluation
 */
public class EvaluationResult {
    /**
     * Evaluator name
     */
    private final String evaluatorName;
    
    /**
     * Evaluation metrics
     */
    private final Map<String, Object> metrics;
    /**
     * Evaluation recommendations
     */
    private final String recommendations;
    /**
     * Whether the evaluation was successful
     */
    private final boolean success;
    /**
     * Evaluation message
     */
    private final String message;

    private EvaluationResult(Builder builder) {
        this.evaluatorName = builder.evaluatorName;
    
        this.metrics = builder.metrics;
        this.recommendations = builder.recommendations;
        this.success = builder.success;
        this.message = builder.message;
    }

    public String getEvaluatorName() {
        return evaluatorName;
    }


    public Map<String, Object> getMetrics() {
        return new HashMap<>(metrics);
    }

    public String getRecommendations() {
        return recommendations;
    }

    public boolean isSuccess() {
        return success;
    }

    public String getMessage() {
        return message;
    }
    @Override
    public String toString(){
        return "{" +
                "'evaluatorName'='" + evaluatorName + '\'' +
                ", 'metrics'=" + metrics +
                ", 'recommendations'=" + recommendations +
                ", 'success'=" + success +
                ", 'message'='" + message + '\'' +
                '}';
    }

    /**
     * Evaluation result builder
     */
    public static class Builder {
        /**
         * Evaluator name
         */
        private String evaluatorName;
        /**
         * Evaluation metrics
         */
        private Map<String, Object> metrics = new HashMap<>();
        private String recommendations = "";
        private boolean success = true;
        private String message = "";

        public static Builder newBuilder() {
            return new Builder();
        }

        public Builder evaluatorName(String evaluatorName) {
            this.evaluatorName = evaluatorName;
            return this;
        }


        public Builder addMetric(String key, Object value) {
            this.metrics.put(key, value);
            return this;
        }

        public Builder addRecommendation(String recommendations) {
            this.recommendations = recommendations;
            return this;
        }

        public Builder success(boolean success) {
            this.success = success;
            return this;
        }

        public Builder message(String message) {
            this.message = message;
            return this;
        }

        public EvaluationResult build() {
            return new EvaluationResult(this);
        }
    }
} 